package itsm.isperp.module.controller.slm;

import itsm.isperp.framework.data.domain.PageResponse;
import itsm.isperp.framework.service.BaseService;
import itsm.isperp.framework.web.controller.BaseController;
import itsm.isperp.framework.web.request.JqGridFilterRuleOp;
import itsm.isperp.framework.web.request.JqGridRequest;
import itsm.isperp.module.entity.slm.SlmUpgradeSetting;
import itsm.isperp.module.service.slm.SlmUpgradeSettingService;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/slm/upgradeSetting")
public class SlmUpgradeSettingController extends
		BaseController<SlmUpgradeSetting> {

	/**
	 * 
	 */
	@Autowired
	protected SlmUpgradeSettingService slmUpgradeSettingService;

	@Override
	public BaseService<SlmUpgradeSetting> getService() {
		return slmUpgradeSettingService;
	}

	@Override
	public String getPageTitle() {
		return "升级规则";
	}

	@RequestMapping("listByAgreement")
	@ResponseBody
	public PageResponse<Map<String, Object>> listByAgreement(
			JqGridRequest request, HttpServletRequest req) {

		String agreementId = req.getParameter("agreementId");
		if (StringUtils.isEmpty(agreementId)) {
			return null;
		}

		request.isPageable(false).addFilterRule("agreement_id",
				JqGridFilterRuleOp.eq, agreementId);
		return this.getService().findAllDetailByRequest(request).toPage();

	}

}